package com.ruoyi.project.xcx.controller;

import java.util.List;

import com.ruoyi.login.LoginServerTest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.xcx.domain.XcxBanna;
import com.ruoyi.project.xcx.service.IXcxBannaService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 小程序bannaController
 * 
 * @author ruoyi
 * @date 2020-06-10
 */
@RestController
@RequestMapping("/xcx/banna")
public class XcxBannaController extends BaseController
{

    @Autowired
    private IXcxBannaService xcxBannaService;

    @Autowired
    LoginServerTest loginServerTest;

    /**
     * 查询小程序banna列表
     */
    @PreAuthorize("@ss.hasPermi('xcx:banna:list')")
    @GetMapping("/list")
    public TableDataInfo list(XcxBanna xcxBanna)
    {
        System.out.println(loginServerTest.test1());

        startPage();
        List<XcxBanna> list = xcxBannaService.selectXcxBannaList(xcxBanna);

        return getDataTable(list);
    }

    /**
     * 导出小程序banna列表
     */
    @PreAuthorize("@ss.hasPermi('xcx:banna:export')")
    @Log(title = "小程序banna", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XcxBanna xcxBanna)
    {
        List<XcxBanna> list = xcxBannaService.selectXcxBannaList(xcxBanna);
        ExcelUtil<XcxBanna> util = new ExcelUtil<XcxBanna>(XcxBanna.class);
        return util.exportExcel(list, "banna");
    }

    /**
     * 获取小程序banna详细信息
     */
    @PreAuthorize("@ss.hasPermi('xcx:banna:query')")
    @GetMapping(value = "/{bid}")
    public AjaxResult getInfo(@PathVariable("bid") Long bid)
    {
        return AjaxResult.success(xcxBannaService.selectXcxBannaById(bid));
    }

    /**
     * 新增小程序banna
     */
    @PreAuthorize("@ss.hasPermi('xcx:banna:add')")
    @Log(title = "小程序banna", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XcxBanna xcxBanna)
    {
        return toAjax(xcxBannaService.insertXcxBanna(xcxBanna));
    }

    /**
     * 修改小程序banna
     */
    @PreAuthorize("@ss.hasPermi('xcx:banna:edit')")
    @Log(title = "小程序banna", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XcxBanna xcxBanna)
    {
        return toAjax(xcxBannaService.updateXcxBanna(xcxBanna));
    }

    /**
     * 删除小程序banna
     */
    @PreAuthorize("@ss.hasPermi('xcx:banna:remove')")
    @Log(title = "小程序banna", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bids}")
    public AjaxResult remove(@PathVariable Long[] bids)
    {
        return toAjax(xcxBannaService.deleteXcxBannaByIds(bids));
    }
}
